package com.ccc.scala.base11_generic

object Generic04 {
  def main(args: Array[String]): Unit = {
    // 泛型上限
    val parent = new Parent
    val user = new User
    val subUser = new SubUser

    // test[Parent](parent) // ERROR
    test[User](user) // OK
    test[SubUser](subUser) // OK
  }

  def test[A <: User](a: A): Unit = {
    println(a)
  }

  class Parent {
  }

  class User extends Parent {
  }

  class SubUser extends User {
  }

}
